# -*- coding: utf-8 -*-
"""
Created on Tue Oct 23 20:14:45 2012

@author: Vinicio Gomez
"""
 
from PyQt4 import QtCore, QtGui
from SearchFaces import Ui_SearchDialog
from RBT import Estudiante
from RBT import RedBlackTree

b = RedBlackTree()
contador=1
#The GUI is call and use, all the graphical manager is here
class SearchFace(QtGui.QDialog):  
   
  def __init__(self, c, parent=None):
    global b
    b=c
    QtGui.QWidget.__init__(self, parent)  
    self.ui = Ui_SearchDialog()                                                       # New Main Window
    self.ui.setupUi(self)
    
    
    #Connections, check events    
    QtCore.QObject.connect(self.ui.cancelButton,
                            QtCore.SIGNAL("clicked()"), 
                            self.exit_window )   
    QtCore.QObject.connect(self.ui.okButton,
                            QtCore.SIGNAL("clicked()"), 
                            self.search)    
    self.exec_()
                                                    
  def exit_window(self):
    self.close()                                                                # Close Windows
  
  def search(self):
    global b
    #buscar a estudiante por carnet
    
    self.estudiante = b.Search( self.ui.carneCampo.text() )
    self.scene=QtGui.QGraphicsScene()
    self.scene.addPixmap(QtGui.QPixmap(str(self.estudiante.getPath())))                                # Set frame
    #print str(self.estudiante.getPath())
    self.ui.caraImagen.setScene(self.scene)
    self.ui.nombreCampo.setText(self.estudiante.getNombre())
    #except:
        #self.ui.nombreCampo.setText("No encontrado")